<?php

namespace app\common\controller;

// 应用公共文件
class Logs extends Base{
	function addLog($action){
		if(request()->module()=="admin"){
			$log['emp_id'] = $this->admin['AdminId'];
			$log['emp_name'] = $this->admin['AdminName'];
		}else if(request()->module()=="index"){
			$log['emp_id'] = $this->user['Id'];
			$log['emp_name'] = $this->user['NickName'];
		}else{
			$log['emp_id'] = 0;
			$log['emp_name'] = '系统';
		}
		
		if(request()->module()=="time"){
			$log['Event'] = "定时任务";
		}else{
			$log['Event'] = request()->action();
		}
		
		$log['create_time'] = time();
		$log['IP'] = request()->ip();
		$log['Description'] = $action;
		$res = db('logs')->insert($log);
	}
}